package Demo;

import java.util.concurrent.BlockingQueue;

public class ProducerQueue implements Runnable{

    private  BlockingQueue<Goods> blockingQueue;
    private  Object object;

    public ProducerQueue() {
    }

    public ProducerQueue(BlockingQueue<Goods> blockingQueue) {
        this.blockingQueue = blockingQueue;
    }

    public BlockingQueue<Goods> getBlockingQueue() {
        return blockingQueue;
    }

    public void setBlockingQueue(BlockingQueue<Goods> blockingQueue) {
        this.blockingQueue = blockingQueue;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            Goods goods=null;
            if (i%2==0){
                goods=new Goods("哇哈哈","矿泉水");
            }else{
                goods=new Goods("旺仔","小馒头");
            }

            try {
                    System.out.println("生产者生产了"+goods.getBrand()+"---"+goods.getName());
                    this.blockingQueue.put(goods);

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
